package cn.hsa.xxx.salesReport.dto;


import cn.hsa.xxx.api.dto.BookSalesMonitorDTO;
import cn.hsa.xxx.salesReport.entity.BookSalesMonitorDO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Component;

@Component
public class BookSalesMonitorDTOConverter {

    /**
     * Convert BookSalesMonitorDTO to BookSalesMonitorDO
     *
     * @param bookSalesMonitorDTO
     * @return
     */
    public BookSalesMonitorDO convertToBookSalesMonitorDO(BookSalesMonitorDTO bookSalesMonitorDTO) {
        if (bookSalesMonitorDTO == null) {
            return null;
        }
        BookSalesMonitorDO bookSalesMonitorDO = new BookSalesMonitorDO();

        //BookSalesMonitorDO.setId(BookSalesMonitorDTO.getId());
        //BookSalesMonitorDO.setName(BookSalesMonitorDTO.getName());
        //BookSalesMonitorDO.setSex(BookSalesMonitorDTO.getSex());
        //BookSalesMonitorDO.setAddr(BookSalesMonitorDTO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(bookSalesMonitorDTO, bookSalesMonitorDO);

        return bookSalesMonitorDO;
    }

    /**
     * Convert BookSalesMonitorDO to BookSalesMonitorDTO
     *
     * @param bookSalesMonitorDO
     * @return
     */
    public BookSalesMonitorDTO convertToBookSalesMonitorDTO(BookSalesMonitorDO bookSalesMonitorDO) {
        if (bookSalesMonitorDO == null) {
            return null;
        }

        BookSalesMonitorDTO bookSalesMonitorDTO = new BookSalesMonitorDTO();

        //BookSalesMonitorDTO.setId(BookSalesMonitorDO.getId());
        //BookSalesMonitorDTO.setName(BookSalesMonitorDO.getName());
        //BookSalesMonitorDTO.setSex(BookSalesMonitorDO.getSex());
        //BookSalesMonitorDTO.setAddr(BookSalesMonitorDO.getAddr());

        //性能略差，但使用方便
        BeanUtils.copyProperties(bookSalesMonitorDO, bookSalesMonitorDTO);

        return bookSalesMonitorDTO;
    }
}
